package com.liuduidui.sh.controller;

import com.liuduidui.sh.feign.UserFeignApi;
import com.liuduidui.sh.pojos.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("feign")
public class FeignController {
    @Autowired
    UserFeignApi userFeignApi;

    @GetMapping("/{id}")
//    @HystrixCommand(fallbackMethod = "queryByIdFallback")
    public User queryById(@PathVariable("id") String id) {
        return userFeignApi.queryById(id);
    }

    //降级方法
//    public User queryByIdFallback(@PathVariable("id") String id) {
//        User user = new User();
//        user.setUsername(id);
//        user.setName("暂停服务");
//        return user;
//    }
}